<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>扫码支付DEMO</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body style="text-align:center">

<div class="contrainer">
    <h3>扫码支付DEMO</h3>
    <hr/>
    <p id="showbox"></p>
    <p class="help-block">请使用其它手机微信扫描二维码。</p>
    <hr/>
    <p class="price">金额: 0.01元</p>
    <hr/>
    <p id="orderno"></p>
    <hr/>
    <button data-reset class="btn btn-default hide">重置订单号</button>
    <a href="{:url('payjs')}" class="btn btn-link">JSAPI支付测试</a>
</div>

</body>
<script src="//cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
<script src="//cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
    $(function () {

        payTest.call(this), setInterval(payTest, 3000);

        /*! 支付测试动作 */
        function payTest() {
            $.get('{:url("payqrc")}', {'action': 'payqrc'}, function (ret) {
                if (ret.code === 2) {
                    $('[data-reset]').removeClass('hide');
                    ret.url = '__STATIC__/theme/default/img/wechat/qrc_payed.jpg';
                }
                $('#showbox').html('<img style="width:300px" class="img-thumbnail" src="' + ret.url + '"/>');
                $('#orderno').html('订单号：' + ret.order_no);
            });
        }

        $('[data-reset]').on('click', function () {
            $.get('{:url("payqrc")}', {'action': 'reset'}, function () {
                window.location.reload();
            });
        });
    });
</script>
</html>